<style>
  .form-condensed select.form-control {height:250px}
  #featurebar > .nav > li > a > .icon-home {display: none}
  .group-item {display:block; width:200px; float:left; font-size: 14px}
</style>
<form target="hiddenwin" method="post" class="form-condensed">
  <div id="featurebar">
    <div class="heading"><i class="icon-lock"> <?php echo isset($info['name']) ? $info['name'] : ''; ?><?php echo isset($info['group_name']) ? $info['group_name'] : ''; ?></i></div>
    <ul class="nav">
      <li class="active">
        <a href="<?php echo U('admin/acl/'.ROUTER_A, array('id' => $id));?>">所有权限</a>
      </li>
      <?php
          $son = Kj\Admin\Libraries\Tree::getSonKey();
          $all = array();
          foreach($tree as $key => $value):
            if( ! isset($value[$son])) continue;
                      
      ?>
      <li class="active">
        <a href="<?php echo U('admin/acl/'.ROUTER_A, array('id' => $id, 'pid' => $value['id']));?>"><?php echo $value['name']; ?></a>
      </li>
      <?php
          endforeach;
      ?>

      
    </ul>
  </div>
  <table class="table table-hover table-striped table-bordered table-form"> 
    <thead>
      <tr>
        <th colspan="2">选项</th>
        <th>配置</th>
      </tr>
    </thead>
    <tbody>
    
    <!-- begin -->
    <?php
        $all = array();
        foreach($tree as $key => $value):
            if( ! isset($value[$son]) or ($pid && $value['id'] != $pid)) continue;
                $all[] = $value['id'];
                $count = count($value[$son]);
                $mark = 0;
                foreach($value[$son] as $key2 => $value2):
                  $all[] = $value2['id'];
                    
    ?>
    <tr class="even" id="m<?php echo $value['id']; ?>">
        <?php if($mark == 0): ?>
        <th class="text-right w-100px" rowspan="<?php echo $count;?>">
            <!-- b -->
            <a onclick="$('#h_<?php echo $value['id']; ?>').click();" class="acl-set-all" href="javascript:;" title="点击我全选"><?php echo $value['name']; ?></a>
            <input id="h_<?php echo $value['id']; ?>" type="checkbox" onclick="selectAllPermission(this, 'm<?php echo $value['id']; ?>', 'checkbox')" style="display:none;" />
            <!-- e -->
            
            <input type="checkbox" <?php if(in_array($value['id'], $hasPermissions)) echo 'checked'; ?>  value="<?php echo $value['id']; ?>" name="permission[]">
        </th>
        <?php endif; ?>
        <td class="pv-10px w-130px" style="padding-left:10px;">
            <!-- b -->
            <a onclick="$('#h_<?php echo $value2['id']; ?>').click();" class="acl-set-all" href="javascript:;" title="点击我全选"><?php echo $value2['name']; ?></a>
            <input type="checkbox" <?php if(in_array($value2['id'], $hasPermissions)) echo 'checked'; ?>  value="<?php echo $value2['id']; ?>" name="permission[]" style="float:right;">
            <!-- e -->
            
            <input id="h_<?php echo $value2['id']; ?>" type="checkbox" onclick="selectAllPermission(this, 'm<?php echo $value2['id']; ?>', 'checkbox')" style="display:none;">
        </td>
        <td class="pv-10px" id="m<?php echo $value2['id']; ?>">
            <?php
                if(isset($value2[$son])):
                    foreach($value2[$son] as $key3 => $value3):
                      $all[] = $value3['id'];
            ?>
            <div class="group-item">
                <input type="checkbox" <?php if(in_array($value3['id'], $hasPermissions)) echo 'checked'; ?> value="<?php echo $value3['id']; ?>" name="permission[]">
                <span id="index-index" class="priv"><?php echo $value3['name']; ?></span>
            </div>
            <?php
                    endforeach;
                endif;
            ?>
        </td>
    </tr>
    
    <?php
                $mark++;
            endforeach;
        endforeach;
    ?>
    <!-- end --> 
    
    <tr>
      <th class="text-right" colspan="2">全选
      <input type="checkbox" onclick="selectAllPermission(this, '', 'checkbox')" >
      </th>
      <td>
         <button class="btn btn-submit btn-primary" data-submitting="提交中..." id="submit" type="submit">保存</button>
         <button class="btn " onclick="javascript:history.go(-1);" type="button">返回</button>
         <input type="hidden" name="id" value="<?php echo $id;?>" />
         <input type="hidden" name="all" value="<?php echo implode(',', $all); ?>" />
      </td>
    </tr>
                
  </tbody>
  </table>
</form>